<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Document</title>
		<style type="text/css">
			
		</style>
	</head>
	<body>
		<label for="">输入一个三位数：</label>
		<input type="text" />
		<input type="button" value="计算" />
	</body>
	<script type="text/javascript">
		var inputs = document.getElementsByTagName('input');

		inputs[1].onclick = function(){
			if (inputs[0].value.length != 3) {
				alert("不是三位数");
				return;
			}
			if (isNaN(Number(inputs[0].value))) {
				alert("不是纯数字");
				return;
			}

			var number = Number(inputs[0].value);
			// 456  789
			var gw = number % 10;
			var sw = parseInt(number % 100 / 10);
			var bw = parseInt(number / 100);
			if (gw * gw * gw + sw * sw *sw + bw * bw * bw ==number) {
				alert("是水仙花数");
			} else {
				alert("不是")
			}
		}






	</script>
</html>